﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASAermod.FileLayers
{


    //简化坐标说明里只有极坐标，回头再看有没有其他的



    /// <summary>
    /// 极坐标网格接受体
    /// </summary>
    public class GRIDPOLR
    {
        string _GRIDID;

        /// <summary>
        /// 
        /// 网格编号
        /// </summary>
        public string GRIDID
        {
          get { return _GRIDID; }
          set { _GRIDID = value; }
        }



        string _ORIG;

        /// <summary>
        /// 极坐标原点
        /// </summary>
        public string ORIG
        {
            get { return _ORIG; }
            set { _ORIG = value; }
        }

        string _DIST;

        /// <summary>
        /// 极坐标的输出距离 100 200 300 500
        /// </summary>
        public string DIST
        {
            get { return _DIST; }
            set { _DIST = value; }
        }

        string _GDIR;

        /// <summary>
        /// 极坐标输出角度
        /// 36 10 10 表示36个角度，10度开始，10度递增
        /// </summary>
        public string GDIR
        {
            get { return _GDIR; }
            set { _GDIR = value; }
        }



       
    }


    /// <summary>
    /// 写这些东西，需要注意不要过度设计，因为只是简单的文件写方法，之后可能会要求支持读
    /// </summary>
    public class AermapInp
    {


        //CO SO RE OU  
        //so 可选



         
        string _TITLEONE = "Terrain Data Preprocess";

        public string TITLEONE
        {
            get { return _TITLEONE; }
            set { _TITLEONE = value; }
        }


        string _TERRHGTS = "EXTRACT";

        public string TERRHGTS
        {
            get { return _TERRHGTS; }
            set { _TERRHGTS = value; }
        }


        string _DATATYPE = "DEM1";

        public string DATATYPE
        {
            get { return _DATATYPE; }
            set { _DATATYPE = value; }
        }


        List<string> _dataFiles = new List<string>();

        public List<string> DataFiles
        {
            get { return _dataFiles; }
            set { _dataFiles = value; }
        }


        string _DOMAINXY;

        public string DOMAINXY
        {
            get { return _DOMAINXY; }
            set { _DOMAINXY = value; }
        }

        string _ANCHORXY;

        public string ANCHORXY
        {
            get { return _ANCHORXY; }
            set { _ANCHORXY = value; }
        }



        string _RUNORNOT = "RUN";

        public string RUNORNOT
        {
            get { return _RUNORNOT; }
            set { _RUNORNOT = value; }
        }





        List<GRIDPOLR> _lstGridPolar = new List<GRIDPOLR>();

        public List<GRIDPOLR> LstGridPolar
        {
            get { return _lstGridPolar; }
            set { _lstGridPolar = value; }
        }



        string _RECEPTOR = "aermap.REC";

        public string RECEPTOR
        {
            get { return _RECEPTOR; }
            set { _RECEPTOR = value; }
        }


        public void WriteFile(string path)
        {

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("CO STARTING");

            sb.AppendLine("TITLEONE " + this._TITLEONE);

            sb.AppendLine("TERRHGTS " + this._TERRHGTS);

            sb.AppendLine("DATATYPE " + this.DATATYPE);

            foreach (string item in this.DataFiles)
            {
                sb.AppendLine("DATAFILE " + item);

            }


            sb.AppendLine("DOMAINXY " + this.DOMAINXY);

            sb.AppendLine("ANCHORXY " + this.ANCHORXY);



            sb.AppendLine("RUNORNOT " + this.RUNORNOT);

            sb.AppendLine("CO FINISHED");


            /////////////////////////////////////////

            sb.AppendLine("RE STARTING");

            foreach (GRIDPOLR item in this.LstGridPolar)
            {
                sb.AppendLine("RE GRIDPOLR "+item.GRIDID+" STA");



                sb.AppendLine(item.GRIDID+" ORIG "+item.ORIG);

                sb.AppendLine(item.GRIDID+" DIST "+item.DIST);

                sb.AppendLine(item.GRIDID+" GDIR "+item.GDIR);



                sb.AppendLine("RE GRIDPOLR "+item.GRIDID+" END");


                
            }


            sb.AppendLine("RE FINISHED");


            /////////////////////////////////////////

            sb.AppendLine("OU STARTING");

            sb.AppendLine("RECEPTOR " +this.RECEPTOR);

            sb.AppendLine("OU FINISHED");


        }


    }
}
